package com.wxtl.action;

import java.util.ArrayList;
import java.util.List;

import com.wxtl.action.base.BaseAction;
import com.wxtl.entity.Agent;
import com.wxtl.service.AgentService;
import com.wxtl.util.Page;

/**
 * 代理商相关action
 * @author liulin
 * @version 2012-12-29
 */
public class AgentAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7822557905151117196L;

	private Agent agent=new Agent();

	private AgentService agentService;
	
	private List<Agent> alist = new ArrayList<Agent>();

	public List<Agent> getAlist() {
		return alist;
	}

	public void setAlist(List<Agent> alist) {
		this.alist = alist;
	}

	public Agent getAgent() {
		return agent;
	}

	public void setAgent(Agent agent) {
		this.agent = agent;
	}

	public AgentService getAgentService() {
		return agentService;
	}

	public void setAgentService(AgentService agentService) {
		this.agentService = agentService;
	}
	
	public String register(){
		Agent a= agentService.add(agent);
		this.getJson().setMsg(a.getAgentsn());
		return SUCCESS;
	}
	
	public String query(){
		Page pageData=agentService.query(super.getDataGrid(),agent);
		setPageData(pageData);
		return SUCCESS;
	}
	
	public String queryAllAgent(){
		setAlist(agentService.getAllAgent());
		return SUCCESS;
	}
}
